<template>
  <el-page-header icon="" title="企业门户网站管理系统">
    <template #content>
      <span class="text-large font-600 mr-3"> 首页 </span>
    </template>
  </el-page-header>
  <el-card class="box-card">
    <el-row>
      <el-col :span="4">
        <el-avatar :size="100" :src="avatarUrl" />
      </el-col>
      <el-col :span="20">
        <h3 style="line-height: 100px;">
          欢迎{{ store.state.userInfo.username }}回来,
          {{welcomeText}}
        </h3>
      </el-col>
    </el-row>
  </el-card>
  <el-card class="box-card">
    <template #header>
      <div class="card-header">
        <span>公司产品</span>
      </div>
    </template>
    <el-carousel :interval="4000" type="card" height="200px">
      <el-carousel-item v-for="item in 6" :key="item">
        <h3 text="2xl" justify="center">{{ item }}</h3>
      </el-carousel-item>
    </el-carousel>
  </el-card>
</template>

<script setup>
//测试用的
// import axios from "axios";
// axios.get("/adminapi/user/home").then((res) => {
//   console.log("获取首页数据", res.data);
// });


import { useStore } from "vuex";
import { computed } from "vue";

//获取登陆成功后后端返回的用户信息
const store = useStore();

// console.log("store的用户信息 持久化", store);
//获取用户头像-计算属性
const avatarUrl = computed(() => {
  return store.state.userInfo.avatar
    ? store.state.userInfo.avatar
    : "https://img.yzcdn.cn/vant/cat.jpeg";//默认是一只猫头像
});
//获取欢迎语-计算属性 12点前是早上，12点后是下午
const welcomeText = computed(() => new Date().getHours()<12 ? '要开心每一天':'喝杯咖啡提提神吧');
</script>

<style scoped lang="scss">
.box-card {
  margin-top: 50px;
}
//element 卡片 轮播图
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
